#!/bin/sh

ver_new="$1"
ver_old="$2"

if [ "$(apk version -t "$ver_old" "4.1.0-r0")" = "<" ]; then
	cat >&2 <<-EOF
		*
		* The pgpool's configuration files were moved from /etc to /etc/pgpool.
		* Files /etc/pgpool.conf, /etc/pcp.conf and /etc/pg_hba.conf will be
		* automatically moved to the new location, if exists. However, you should
		* still check your configuration; pay attention to relative paths!
		*
	EOF

	for f in pgpool.conf pcp.conf pg_hba.conf; do
		if [ -f /etc/$f ] && ! [ -f /etc/pgpool/$f.apk-new ]; then
			mv -v /etc/$f /etc/pgpool/
		fi
	done
fi

exit 0
